﻿<%@ Page Language="C#" Title="历史数据" MasterPageFile="~/W_View/PageMaster.Master" CodeBehind="Dm_HistperfPage.aspx.cs" Inherits="STHPMS1.Web.W_View.Decision.Dm_HistperfPage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <%= UiHelper.RefJsFileHtml("/Scripts/Control/datagrid.js")%>

    <script type="text/javascript">      

        var _mainsegid;
		function Dm_HistperfEdit(flag)
        {
		    var row = $('#dg').datagrid('getSelected');
		    var title = "";
		    if (flag == 0) {
		        if (!row) {
		            $.messager.alert('消息提示', '编辑数据时，请选择一项!', 'warning');
		            return;
		        }
		        $('#fm').form('load', row);
		        title = "新增测试数据";
		    }
		    else {
		        $('#fm').form('clear');
		        $('#fm').form('load', {
		            Perfyear: new Date().getFullYear()
		        });
		        title = "编辑测试数据";
		    }
            $('#dlg').dialog('open');
        }

        function Dm_HistperfDel() {
            var row = $('#dg').datagrid('getSelected');
            if (!row) {
                $.messager.alert('消息提示', '删除数据时，请选择一项!', 'warning');
                return;
            }

            deleteData($('#dg'), $('#dlg'), "/api/histperf");
        }

		
        function search(n, o) {
            var road = $('#cmbRoads').combobox("getValue");
            var inspecid = $('#cmbInspecid').datebox('getValue');
            var checkDate = $('#checkDate').datebox('getValue');

            var url = '/api/histperf';
            var urlParam = "";
            if (road != "" && road != "0") urlParam += "road=" + encodeURI(road) + "&";
            if (inspecid != "" && inspecid != "0") urlParam += "inspecid=" + encodeURI(inspecid) + "&";
            if (checkDate != "") urlParam += "checkDate=" + encodeURI(checkDate) + "&";
            if (urlParam != "") {
                urlParam = "?" + urlParam.substring(0, urlParam.length - 1);
                url = url + urlParam;
            }

            $('#dg').datagrid({ url: url, pageNumber: 1 });
        }

        $(function () {
            var number= '<%= Page.RouteData.Values["page"] %>';
            var size = '<%= Page.RouteData.Values["size"] %>';

            dataGridBind($('#dg'), '/api/histperf', '历史数据显示', $('#tb'), number, size);

            $('.validatebox-text').bind('blur', function () {
                $(this).validatebox('enableValidation').validatebox('validate');
            });
                 
        })

        function reqSeg(rect) {
            $('#Mainsegid').combobox('clear');

            $.ajax({
                url: '/api/trafaxle/seg?rdwayid=' + rect.id,
                success: function (data1) {
                    type = null;

                    $('#Mainsegid').combobox('loadData', data1);
                },
                error: function (err) {
                    $.messager.alert('错误提示', err.responseJSON.ExceptionMessage, 'error');
                }
            });
        }

        function sync() {
            var rdwayid = $('#cmbRoads').combobox("getValue");
            if (!rdwayid) {
                $.messager.alert('消息提示', '请选择一条路线!', 'warning');
                return;
            }

            $.ajax({
                url: '/api/histperf/sync?rdwayid=' + encodeURI(rdwayid),
                type: "post",
                success: function (data1) {
                    $('#dg').datagrid('reload');
                },
                error: function (err) {
                    $.messager.alert('错误提示', err.responseJSON.ExceptionMessage, 'error');
                }
            });
        }


        function search(n, o) {
            var road = $('#cmbRoads').combobox("getValue");

            var url = '/api/histperf';
            var urlParam = "";
            if (road != "" && road != "0") urlParam += "road=" + encodeURI(road) + "&";
            if (urlParam != "") {
                urlParam = "?" + urlParam.substring(0, urlParam.length - 1);
                url = url + urlParam;
            }

            $('#dg').datagrid({ url: url, pageNumber: 1 });
        }
    </script>    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <table id="dg" class="easyui-datagrid content-place"  ajaxCached="false"  >
        <thead>
            <tr>                
                <th data-options="field:'Mainsegid',editor:'text',width:80,align:'right' ">养护路段</th>
                <th data-options="field:'Perfyear',editor:'text',width:80,align:'right' ">性能数据年份</th>
                <th data-options="field:'Rdwayid',editor:'text',width:80,align:'right' ">路线编号</th>
                <th data-options="field:'Pqiave',editor:'numberbox',width:80,align:'right' ">PQI平均值</th>
                <th data-options="field:'Pciave',editor:'numberbox',width:80,align:'right' ">PCI平均值</th>
                <th data-options="field:'Rqiave',editor:'numberbox',width:80,align:'right' ">RQI平均值</th>
                <th data-options="field:'Rdiave',editor:'numberbox',width:80,align:'right' ">RDI平均值</th>
                <th data-options="field:'Sriave',editor:'numberbox',width:80,align:'right' ">SRI平均值</th>
                <th data-options="field:'Pssave',editor:'numberbox',width:80,align:'right' ">PSSI平均值</th>
                <th data-options="field:'Histaadt',editor:'numberbox',width:80,align:'right' ">历史年份AADT</th>
                <th data-options="field:'Histaaci',editor:'numberbox',width:80,align:'right' ">历史年份事故</th>
                <th data-options="field:'Comments',editor:'text',width:80,align:'right' ">注释</th>
            </tr>
        </thead>
    </table>
   
     <div id="tb">         
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="Dm_HistperfEdit(-1)">添加</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true" onclick="Dm_HistperfEdit(0)">修改</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="Dm_HistperfDel()">删除</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="sync()">同步</a>
        <select id="cmbRoads" class="easyui-combobox" panelHeight="80" style="width:100px" data-options="prompt:'路线编号',url:'/api/roadway/dict',method:'get',valueField:'id',textField:'id',onChange:search">
        </select>
    </div>

    <div id="dlg" class="easyui-dialog" title="保存数据" style="width:400px;height:400px;padding:10px" closed="true"  data-options="
				iconCls: 'icon-save',
				buttons: '#dlg-buttons'
			">
        <form id="fm" method="post" action="/api/histperf">
            <table>		
                <tr>
                    <td>路线编号:</td>
                    <td><input id="Rdwayid" name='Rdwayid'  class="easyui-validatebox  easyui-combobox" data-options="prompt:'路线编号',required:true,valueField:'id',textField:'id',url:'/api/roadway/dict',method:'get' ,onSelect:reqSeg"/></td>
                </tr>        		     
                <tr>
                    <td>养护路段:</td>
                    <td><input id="Mainsegid" name='Mainsegid' class="easyui-validatebox  easyui-combobox" data-options="prompt:'养护路段',required:true,valueField:'Mainsegid',textField:'Mainsegid' ,method:'get',
                            onLoadSuccess:function(data){$('#Mainsegid').combobox('setValue',_mainsegid); _mainsegid=null;}"/></td>
               </tr>
                <tr>
                    <td>性能数据年份:</td>
                     <td><input name='Perfyear' class="easyui-validatebox  easyui-combobox" data-options="prompt:'年份',required:true,val2ueField:'id',textField:'id' ,method:'get',url:'/api/data/years' "/></td>
                </tr>
                <tr>
                    <td>PQI平均值:</td>
                    <td><input name='Pqiave' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>PCI平均值:</td>
                    <td><input name='Pciave' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>RQI平均值:</td>
                    <td><input name='Rqiave' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>RDI平均值:</td>
                    <td><input name='Rdiave' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>SRI平均值:</td>
                    <td><input name='Sriave' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>PSSI平均值:</td>
                    <td><input name='Pssave' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>历史年份AADT:</td>
                    <td><input name='Histaadt' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>历史年份事故:</td>
                    <td><input name='Histaaci' class='easyui-validatebox easyui-numberbox'  data-options='min:0,precision:2' /></td>
                </tr>
                <tr>
                    <td>注释:</td>  
                     <td><input name='Comments' class='easyui-validatebox easyui-textbox'  data-options="validType:'MaxLength[200]',multiline:true" style="width:180px;height:100px"/></td>            
                </tr>
		    </table>
        </form>
    </div>

    <!--编辑数据命令-->
    <div id="dlg-buttons">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:sumbitData($('#dg'),$('#dlg'))">保存</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="javascript:$('#dlg').dialog('close')">取消</a>
	</div>
</asp:Content>
